<?php

class Zhishidi_Dailydeals_Block_Adminhtml_Dailydeals_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {

    protected function _prepareForm() {
        $form = new Varien_Data_Form();
        $this->setForm($form);
        $fieldset = $form->addFieldset('dailydeals_fieldset', array('legend' => Mage::helper('zhishidi_dailydeals')->__("Daily deals information")));

        $fieldset->addField('product_sku', 'text', array(
            'name' => 'product_sku',
            'label' => Mage::helper('zhishidi_dailydeals')->__('Product SKU'),
            'title' => Mage::helper('zhishidi_dailydeals')->__('Product SKU'),
            'class' => 'required-entry',
            'required' => true,
        ));


        $fieldset->addField('deal_price', 'text', array(
            'name' => 'deal_price',
            'label' => Mage::helper('zhishidi_dailydeals')->__('Special Price'),
            'title' => Mage::helper('zhishidi_dailydeals')->__('Special Price'),
            'class' => 'required-entry',
            'required' => true,
        ));


        $fieldset->addField('deal_total', 'text', array(
            'name' => 'deal_total',
            'label' => Mage::helper('zhishidi_dailydeals')->__('Total Qty'),
            'title' => Mage::helper('zhishidi_dailydeals')->__('Total Qty'),
            'class' => 'required-entry',
            'required' => true,
        ));



        $fieldset->addField('deal_limit', 'text', array(
            'name' => 'deal_limit',
            'label' => Mage::helper('zhishidi_dailydeals')->__('Limit Qty'),
            'title' => Mage::helper('zhishidi_dailydeals')->__('Limit Qty'),
            'required' => false,
        ));






        $dateFormatIso = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
        
        $fieldset->addField('deal_from', 'date', array(
            'name' => 'deal_from',
            'title' => Mage::helper('zhishidi_dailydeals')->__("Start Date"),
            'label' => Mage::helper('zhishidi_dailydeals')->__("Start Date"),
            'required' => true,
            'image' => $this->getSkinUrl('images/grid-cal.gif'),
            'input_format' => Varien_Date::DATETIME_INTERNAL_FORMAT,
            'time' => true,
            'format' => $dateFormatIso,
        ));


        $fieldset->addField('deal_to', 'date', array(
            'name' => 'deal_to',
            'title' => Mage::helper('zhishidi_dailydeals')->__("End Date"),
            'label' => Mage::helper('zhishidi_dailydeals')->__("End Date"),
            'required' => true,
            'image' => $this->getSkinUrl('images/grid-cal.gif'),
            'input_format' => Varien_Date::DATETIME_INTERNAL_FORMAT,
            'time' => true,
            'format' => $dateFormatIso,
        ));


        if (!Mage::app()->isSingleStoreMode()) {
            $fieldset->addField('store_id', 'multiselect', array(
                'name' => 'stores[]',
                'label' => Mage::helper('zhishidi_dailydeals')->__('Store View'),
                'title' => Mage::helper('zhishidi_dailydeals')->__('Store View'),
                'required' => true,
                'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
            'style' => 'height:150px',
            ));
        } else {
            $fieldset->addField('store_id', 'hidden', array(
                'name' => 'stores[]',
                'value' => Mage::app()->getStore(true)->getId()
            ));
            #$model->setStoreId(Mage::app()->getStore(true)->getId());
        }


        $fieldset->addField('deal_info', 'textarea', array(
            'name' => 'deal_info',
            'label' => Mage::helper('zhishidi_dailydeals')->__('Info'),
            'title' => Mage::helper('zhishidi_dailydeals')->__('Info'),
            'required' => false,
        ));

        $fieldset->addField('deal_status', 'select', array(
            'name' => 'deal_status',
            'label' => Mage::helper('zhishidi_dailydeals')->__('Status'),
            'title' => Mage::helper('zhishidi_dailydeals')->__('Status'),
            'required' => false,
            'values' => array(
                array(
                    'value' => 'public',
                    'label' => Mage::helper('zhishidi_dailydeals')->__('Public'),
                ),
                array(
                    'value' => 'hidden',
                    'label' => Mage::helper('zhishidi_dailydeals')->__('Hidden'),
                )
            ),
        ));


 

        if (Mage::getSingleton('adminhtml/session')->getDailydealsData()) {
            $form->setValues(Mage::getSingleton('adminhtml/session')->getDailydealsData());
            Mage::getSingleton('adminhtml/session')->setDailydealsData(null);
        } elseif (Mage::registry('dailydeals_data')) {
            $form->setValues(Mage::registry('dailydeals_data')->getData());
        }
        return parent::_prepareForm();
    }

}